package jc.malpractice.service;



import cn.hutool.json.JSONObject;
import jc.malpractice.db.DbUtil;
import jc.malpractice.db.Help;

import java.sql.*;
import java.util.ArrayList;
public class DeptService {
    public static JSONObject sel_dept() {
        Connection conn = DbUtil.getConn();
        System.out.println(conn);
        if (conn == null) return null;

        PreparedStatement preparedStatement = null;
        ResultSet resultSet = null;
        JSONObject jo = new JSONObject();
        try {

            preparedStatement = conn.prepareStatement(
                    "select * from department");

            resultSet = preparedStatement.executeQuery();

            jo = Help.Result2Json(resultSet);
            return jo;

        } catch (SQLException e) {
            try {

            } catch (Exception ee) {
                System.out.println(ee.getMessage());
            }

            System.out.println(e.getMessage());
        } finally {
            try {
                if (resultSet != null) resultSet.close();
                if (preparedStatement != null) preparedStatement.close();
                conn.close();
            } catch (SQLException e) {
                System.out.println(e.getMessage());
            }
        }

        return jo;
    }
}
